package com.xc.erp.modules.erp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xc.erp.common.utils.StringUtils;
import com.xc.erp.modules.erp.domain.pojo.JshLog;
import com.xc.erp.modules.erp.domain.vo.LogUserVo;
import com.xc.erp.modules.erp.service.JshLogService;
import com.xc.erp.modules.erp.mapper.JshLogMapper;
import io.jsonwebtoken.lang.Objects;
import org.springframework.stereotype.Service;

/**
 *
 */
@Service
public class JshLogServiceImpl extends ServiceImpl<JshLogMapper, JshLog>
    implements JshLogService{

    @Override
    public IPage<LogUserVo> logListPage(Integer page, Integer limit, LogUserVo logUserVo) {
        IPage<LogUserVo> pageModel = new Page<>(page,limit);
        QueryWrapper<LogUserVo> wrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(logUserVo.getOperation())){
            wrapper.like("operation",logUserVo.getOperation());
        }
        if (!StringUtils.isEmpty(logUserVo.getContent())){
            wrapper.like("content",logUserVo.getContent());
        }
        if (!StringUtils.isEmpty(logUserVo.getStartTime())){
            wrapper.gt("create_time",logUserVo.getStartTime());
        }
        if (!StringUtils.isEmpty(logUserVo.getEndTime())){
            wrapper.lt("create_time",logUserVo.getEndTime());
        }
        if (!StringUtils.isEmpty(logUserVo.getLoginName())){
            wrapper.like("u.login_name",logUserVo.getLoginName());
        }
        if (!StringUtils.isEmpty(logUserVo.getClientIp())){
            wrapper.eq("client_ip",logUserVo.getClientIp());
        }
        if(logUserVo.getStatus() != null){
            wrapper.eq("l.status",logUserVo.getStatus().byteValue());
        }
        pageModel = baseMapper.findByPage(pageModel, wrapper);
        return pageModel;
    }
}




